package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.article.ArticleConstants;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("APP文章首页API")
@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {
    @Autowired
    private ApArticleService apArticleService;
    //@PostMapping("/load")
    //@ApiOperation(value = "查询首页文章列表")
    //public ResponseResult load(@RequestBody ArticleHomeDto dto){
    //    return this.apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    //}
    //@ApiOperation("查询更多文章")
    //@PostMapping("/loadmore")
    //public ResponseResult loadMore(@RequestBody ArticleHomeDto dto){
    //    return this.apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    //}//todo ArticleConstants.DEFAULT_TAG  怎么用
    //@ApiOperation("查询更新文章")
    //@PostMapping("/loadnew")
    //public ResponseResult loadNew(@RequestBody ArticleHomeDto dto){
    //    return this.apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,dto);
    //}
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        //return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
        return apArticleService.load2(ArticleConstants.LOADTYPE_LOAD_MORE,dto,true);
    }
    @ApiOperation(value = "查询更多文章")
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    }
    @ApiOperation(value = "查询最新文章")
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,dto);
    }
}
